'use strict';{const F=document.currentScript.parentElement;var _dy=()=>{function p(a,b){let c=!1;for(let d of b)"<hr>"==d?c=!0:(b=_er(d,"tse"),a[d]=[b.name,b.help?"/tse/"+b.help:"",c&&!(c=!1)])}function q(a){if(a&&(_Mg(a.refTab)||_Mg(a.tabSet)))return a.refTab||a.tabSet}function l(a,b){a=$("<params>"+G[a](b)+"</params>");a.find("[name=refTab], [name=tabSet]").prop("value",q(b));return a}function m(a){let b={};$(">params [name]",$(a).closest("tseOper")).each(function(){b[$(this).attr("name")]=_pu(this)});
return b}function H(a){let b=[];$("> operSeq > tseOper",a).each(function(){b.push({ufOper:$(this).attr("type"),params:m(this)})});return b}function r(a){let b=$(`\n <tseOper type=${a.ufOper}>\n <name>${f.opers[a.ufOper]}</name>\n <params></params>\n <z actions>\n <move><u title="Move up"></u><d title="Move down"></d></move>\n <del button title="Delete"></del>\n </z>\n </tseOper>\n `);b.find(">params").replaceWith(l(a.ufOper,a.params));b[0].savedTSE=q(a.params);return b}function t(a,b=""){let c=k[a].type;
return"string"==c?b==a?"":b:"number"==c?1:Object.keys("bool"==c?f.boolValues:f.enumValues[a])[0]}function I(a){let b=$("~ addMenu",a)[0];b||(b=_Bj($)`\n <addMenu>\n ${[...f.opers].map(([c,d])=>`<item type=${c}>${d} <h h=${c}></h></item>`)}\n </addMenu>\n `.on("close",function(){$(this).hide()}).on("click","> item",function(){$(this).closest("addMenu").triggerEvt("focusLost");let c=$(this).attr("type"),d=r({ufOper:c,params:J[c]}).addClass("beforeShowing");$(this).closest("tseEditor").removeClass("empty").find(">operSeq").append(d);
d[0].scrollIntoView();d.removeClass("beforeShowing");setTimeout(()=>d.triggerEvt("change",!0),400)}).insertAfter(a)[0]);_Jh(b,a,"trlb")}function K(a){a.on("change","[name=tgtExpr]",function(){let b=$(this).closest("tseOper"),c=m(this),d=k[c.tgtExpr].type;"refCond"==d?c.refTab||(c.refTab=b[0].savedTSE||"currentTab"):d.in("favList","evtTabs","mnuSltn","grpSize")||(c.compOper in f["string"==d?"compOpersStr":"compOpers"]||(c.compOper="equals"),c.refExpr="sameAs"==c.compOper?c.tgtExpr:t(c.tgtExpr,$("[type=text][name=refExpr]",
b).val()));$(">params",b).replaceWith(l(b.attr("type"),c))}).on("change","[name=order]",function(){let b=$(this).closest("tseOper"),c=m(this);$(">params",b).replaceWith(l(b.attr("type"),c))}).on("change","[name=compOper]",function(){let b=m(this);"sameAs"==$(this).attr("value")?(b.refTab=$(this).closest("tseOper")[0].savedTSE||"currentTab",b.refExpr=b.tgtExpr):b.refExpr=t(b.tgtExpr,b.refExpr);$(this).closest("params").replaceWith(l("filter",b))}).on("input","[name=from]",function(){0==this.value&&
(this.value=0<this.defaultValue?-1:1);this.defaultValue=this.value;$(this).nextAll("[type=number]").triggerEvt("input",!0)}).on("input","[name=to]",function(){let b=+$(this).prevAll("[type=number]").val(),c=+this.value;0<=c&&c<b?this.value=c>=this.defaultValue?b:-1:0>c&&0>b&&c<b?this.value=b:0==c&&(this.value=0<this.defaultValue?-1:1);this.defaultValue=this.value}).on("change","[name=refTab], [name=tabSet]",function(b,c){b=$(this).closest("tseOper")[0];c?b.savedTSE=this.value:"other"==$(this).attr("value")&&
(this.value=b.savedTSE)}).on("mouseenter mouseleave","[name=refTab]",function(b){let c=_Xt($(this).closest("tseOper")[0]);b="mouseenter"==b.type;$(this).closest("tseEditor").find("tseResult step").eq(c).find("[refTab=true]").toggleClass("highlighted",b)}).on("mousedown","move > *",function(){_Lp($(this).closest("tseOper"),"D"==this.tagName?1:-1);$(this).triggerEvt("change",!0);setTimeout(()=>$(document.elementFromPoint(_ro,_wi)).triggerEvt("mouseover",!0),200)}).on("dblclick","[actions] > del",function(){let b=
$(this).closest("tseOper"),c=b.parent();b.css("visibility","hidden").hide(300,function(){this.remove();c.triggerEvt("change",!0)})}).on("mousedown","footer add",function(){I(this)}).on("mousedown","footer result[show]",function(){let b=$(this).closest("tseEditor").attr("resViewer","on");u(b[0]);b.append(v(b[0].assocElem));b[0].assocElem.showTseResult=!0;_Bd(()=>$("TSEResult > content",b).css("transform","translate(0)"))}).on("mousedown","footer result[hide]",function(){let b=$(this).closest("tseEditor").attr("resViewer",
"off");b.find("TSEResult").remove();b[0].assocElem.showTseResult=!1}).on("mouseenter mouseleave","tseOper, tseResult step:not(:first-of-type)",function(b,c){var d=$(this).closest("tseEditor");if((c||!d.find(":not(h).popup").length)&&"on"==d.attr("resViewer")){c="mouseenter"==b.type;var e="TSEOPER"==this.tagName;d.find("tseOper.hover, tseResult step.hover").removeClass("hover");b=d.find(e?"tseResult step":"tseOper").eq(_Xt(this)+(e?1:-1));c&&b.add(this).addClass("hover");d=b.parent().stop(!0);if(c&&
b.length){c=e?"Width":"Height";e=e?"Left":"Top";let g=+b.css("zoom"),h=b[0]["offset"+c]*g;b=b[0]["offset"+e]*g+h/2-d[0]["offset"+c]/2;Math.abs(d[0]["scroll"+e]-b)>h&&d.delay(200).animate({["scroll"+e]:b},1E3)}}}).on("change input",_Ow(500,function(b){b.stopPropagation();this.assocElem.value=H(this);w(this);$(this.assocElem).triggerEvt({change:!0},!0);u(this)},b=>b.stopPropagation()))}function u(a){$(a).css("--contentMaxWidth","").css("--contentMaxWidth",Math.max($(a).css("--contentDefaultMaxWidth"),
a.offsetWidth))}function w(a){x(a)(()=>{$(a).find("TSEResult").triggerEvt("update")})}function y(a){if(!a.popup){let b=$(`<tabDetails refTab=${$(a).attr("refTab")}>\n <ref>Reference tab for the next step <h h=refTab></h></ref>\n <tit>${_5h($("t",a).text())}</tit>\n <url>${_5h($(a).attr("url"))}</url>\n </tabDetails>`).appendTo(a.closest("tseEditor"));a.popup=_Jh(b,{x:_ro-10,y:_wi-10,w:30,h:30},"rblt","tailAndShadow noTail","","opacity");$(a.popup).on("mouseenter",()=>clearTimeout(a.timer)).on("mouseleave focusLost",
()=>a.closePopup());a.closePopup=function(){this.timer=setTimeout(()=>{this.popup&&this.popup.close();delete this.popup},200)}}}function v(a){function b(){L(c.preprocTSE,a.value,a.initialSet,d=>{$("> content",c).html(d).find("cont").enableResizeEvent().on("resize",function(){$(this).css("--height",$(this).css("height"))});let e=$(c).closest("tseEditor");e.find("tseOper.hover").triggerEvt({mouseover:!0},!0);_Bd(()=>e.find("edit.popup").triggerEvt("resize"))})}let c=$("<TSEResult><content></content></TSEResult>").on("wheel",
">content",function(d){let e=d.originalEvent.deltaY;if(e&&!d.ctrlKey&&!d.shiftKey&&!d.altKey){let g=$(d.target).closest("tabList")[0],h=$(d.target).closest("cont")[0];if((!g||g.clientHeight>=g.scrollHeight)&&(!h||h.clientHeight>=h.scrollHeight))return 49<_Ok?_ko(this,e):this.dispatchEvent(new WheelEvent("wheel",{deltaX:e,deltaMode:d.originalEvent.deltaMode})),!1}}).on("mouseenter","tab",function(){clearTimeout(this.timer);this.timer=setTimeout(()=>document.contains(this)&&y(this),$("tabDetails")[0]?
1E3:1500)}).on("mousedown","tab",function(){y(this)}).on("mouseleave","tab",function(){clearTimeout(this.timer);this.popup&&this.closePopup()}).on("mouseenter mouseleave","[refTab=true]",function(d){let e=_Xt(this.closest("step"));d="mouseenter"==d.type;$("tseOper",this.closest("tseEditor")).eq(e).find("[name=refTab]").toggleClass("highlighted",d)}).on("update",function(){this.preprocTSE=_hf._Ei(a.value);setTimeout(b,200)})[0];c.preprocTSE=_hf._Ei(a.value);b();return $(c)}const f={opers:{filter:"Filter",
slice:"Slice",sort:"Sort",groupBy:"Group by",mergeGrp:"Merge groups",addSet:"Add tabs"},compOpers:{equals:"equals",sameAs:["same as","../refCmp"]},compOpersStr:{equals:"equals",contains:"contains",starts:"starts with",ends:"ends with",sameAs:["same as","../refCmp"]},boolValues:{true:"On",false:"Off"},enumValues:{"<status>":{loading:"Loading",complete:"Loaded",discarded:"Unloaded"},"<window.type>":{normal:"Normal",popup:"Pop-up",devtools:"DevTools"},"<window.state>":{normal:"Normal",minimized:"Minimized",
maximized:"Maximized",fullscreen:"Full screen",hidden:"Hidden"},"<monitorId>":{}},sortOrder:{normal:["Normal order","nrm"],mru:["Use order","mru"],creation:["Open order","opn"],zOrder:["Stacking order","zOrd"],"<title>":"By title","<url>":"By URL","<domain>":["By URL domain","dom"],"<url.mainDomain>":["By main domain","mdom"],"<path>":["By URL path","pth"],reverse:["Reverse order","inv"]},groupBy:{"<windowId>":["Window","win"],"<window.type>":["Window type","wTy"],"<window.state>":["Window state",
"wSt"],"<monitorId>":["Monitor","mon"],overlapArea:["Overlapping","ovr"],"<groupId>":["Tab-strip group","tGr"],"<title>":["Title","tit"],"<url>":["URL","url"],"<domain>":["URL domain","dom"],"<url.mainDomain>":["Main domain","mdom"],"<path>":["URL path","pth"],"<highlighted>":["Selected state","hl"],"<pinned>":["Pin state","pin"],"<audible>":["Audible state","aud"],"<muted>":["Mute state","mut"],"<status>":["Load status","sts"],"<incognito>":["Incognito mode","icg"]}};p(f.refTabs={},"currentTab prevUsedTab openerTab activeTab firstTab lastTab eventTabs hoveredTabs".split(" "));
f.refTabs.other="Other tab... <edit></edit>";f.addSetOpts=()=>{let a={};p(a,["highlighted","pinnedTabs","audibleTabs","nonMinimTabs","allLeftTabs","allRightTabs","otherTabs","otherTabsAllWins","currWinTabs","allTabs","<hr>",..._Ws("tse",!0)]);a.other=["Other tabs... <edit></edit>","",!0];return a};const k={"<active>":{type:"bool",label:["Active state","act"]},"<highlighted>":{type:"bool",label:["Selected state","hl"]},"<pinned>":{type:"bool",label:["Pinned state","pin"]},"<audible>":{type:"bool",
label:["Audible state","aud"]},"<muted>":{type:"bool",label:["Muted state","mut"]},"<used>":{type:"bool",label:["Used state","usd"]},"<status>":{type:"enum",label:["Load status","sts"]},"<incognito>":{type:"bool",label:["Incognito mode","icg"]},"<grouped>":{type:"bool",label:["Grouped state","grp"]},"<hovered>":{type:"bool",label:["Hovered state","hvr"]},"<index>":{type:"number",label:["Tab position","idx"]},menuSeltn:{type:"mnuSltn",label:["Menu selection","mSl"]},prev:{type:"refCond",label:["Tab before",
"prv",!0]},before:{type:"refCond",label:["All tabs before","bef"]},next:{type:"refCond",label:["Tab after","nxt"]},after:{type:"refCond",label:["All tabs after","aft"]},grpSize:{type:"grpSize",label:["Group size","grS",!0]},windowId:{type:"refCond",label:"Tabs in same window as"},groupId:{type:"refCond",label:["Tabs in same group as","tGr"]},openerTabId:{type:"refCond",label:"Tabs opened by"},favList:{type:"favList",label:["Tabs in favorite list","fav"]},evtTabs:{type:"evtTabs",label:["Event tabs",
"evt"]},"<url>":{type:"string",label:["URL","url",!0]},"<domain>":{type:"string",label:["URL domain","dom"]},"<url.mainDomain>":{type:"string",label:["Main domain","mDom"]},"<path>":{type:"string",label:["URL path","pth"]},"<title>":{type:"string",label:["Title","tit"]},"<window.focused>":{type:"bool",label:["Window focus state","foc",!0]},"<window.type>":{type:"enum",label:["Window type","wTy"]},"<window.state>":{type:"enum",label:["Window display state","wSt"]},"<window.alwaysOnTop>":{type:"bool",
label:["Window topmost state","aot"]},"<window.underMouse>":{type:"bool",label:["Window hovered state","pnt"]},"<monitorId>":{type:"enum",label:["Monitor","mon",!0]}};for(let a in k){let b=k[a];_ih(f,"tabExpr")[a]=b.label;b.type.in("bool","string","number")&&(_ih(f,"tabExpr_"+b.type)[a]=b.label)}const J={filter:{tgtExpr:"<active>",compOper:"equals",refExpr:!0},slice:{from:1,to:-1},sort:{order:"mru"},mergeGrp:{},groupBy:{expr:"<windowId>"},addSet:{tabSet:"highlighted"}},G={filter:a=>{let b=k[a.tgtExpr].type,
c=_Mg(a.refTab)?"other":a.refTab,d="string"==b?"compOpersStr":"compOpers",e=b.in("bool","string")?"tabExpr_"+b:"",g=` &nbsp; <label>${_io("negate",+a.negate)} inverse filter</label> &nbsp; <w><h h=neg></h></w>`;return`\n ${_Qp(f.tabExpr,"tgtExpr",a.tgtExpr,17,"helpCtx")}\n ${"refCond"==b?`\n ${_bp(f,"refTabs","refTab",c,"",'title="Choose a reference tab"')}\n ${a.tgtExpr.in("openerTabId","windowId","groupId")?g:(a.tgtExpr.in("before","after")?` &nbsp; <label>${_io("addRef",a.addRef)} include ref. tab</label> &nbsp; <w><h h=adRf></h></w>&nbsp;`:
"")+` &nbsp; <label>${_io("wrap",a.wrap)} circular list</label> &nbsp; <w><h h=wrp></h></w>`}\n `:"favList"==b?`\n ${_ow(_kp,a.favList,"favList")} ${g}\n `:"evtTabs"==b?`\n ${g}\n `:"mnuSltn"==b?`\n ${_ow({0:"",1:"not"},a.negate,"negate","bool")}\n <label>${_io("marked",a.marked)}Marked</label> &nbsp; &nbsp;\n <label>${_io("hilited",a.hilited)}Hilited</label> &nbsp; &nbsp;\n <label>${_io("hovered",a.hovered)}Hovered</label> &nbsp; &nbsp; <w><h h=mSl></h></w>\n `:"grpSize"==b?`\n &nbsp; &nbsp; Min. tabs: <input type=number name=min value="${a.min||
1}" min=1 autocomplete=off> &nbsp; <w><h h=mnMxGS></h></w> &nbsp; &nbsp;\n Max. tabs: <input type=number name=max value="${a.max||999}" min=1 autocomplete=off>\n `:`\n ${_ow({0:"",1:"not"},a.negate,"negate","bool")}\n ${_bp(f,d,"compOper",a.compOper,"","helpCtx")}\n ${"sameAs"==a.compOper?`<tabExpr>\n ${_bp(f,"refTabs","refTab",c,"",'title="Choose a reference tab"')}\n ${_Qp(f[e]||{[a.refExpr]:f.tabExpr[a.refExpr]},"refExpr",a.refExpr,"","helpCtx")}\n <!--customSelect options="${e}" name=refExpr value="${a.refExpr}" helpCtx>${_3y(f.tabExpr[a.refExpr])[0]}</customSelect-->\n </tabExpr>`:
"bool"==b?_ow(f.boolValues,a.refExpr,"refExpr"):"enum"==b?_ow(f.enumValues[a.tgtExpr],a.refExpr,"refExpr"):"number"==b?`<input type=number name=refExpr min=1 value=${a.refExpr}>`:_if("refExpr",a.refExpr,"Enter text...","autoDim")}\n `}\n `},slice:a=>`\n From: <input type=number name=from value="${a.from}" autocomplete=off> &nbsp; <w><h h=frTo></h></w>&nbsp;\n To: <input type=number name=to value="${a.to}" autocomplete=off> &nbsp; &nbsp; &nbsp;\n <label>${_io("groupWise",a.groupWise)}group-wise</label> &nbsp; <w><h h=grWs></h></w>\n `,
sort:a=>`\n ${_bp(f,"sortOrder","order",a.order,"","helpCtx")}\n ${"reverse"==a.order?`<label>${_io("groupWise",a.groupWise)}group-wise</label> &nbsp; <w><h h=grWs></h></w>`:`${_ow({0:"Ascending",1:"Descending"},a.desc,"desc","number")} &nbsp; <w><h h=dsc></h></w>`}\n `,groupBy:a=>_bp(f,"groupBy","expr",a.expr,"","helpCtx"),mergeGrp:a=>"<w> &nbsp; &nbsp; &nbsp; <nop>No options available</nop></w>",addSet:a=>{let b=_Mg(a.tabSet)?"other":a.tabSet;return`\n ${_bp(f,"addSetOpts","tabSet",b)} &nbsp; &nbsp;\n <label>${_io("replace",
a.replace)}Replace</label> &nbsp; <w><h h=repl></h></w>\n `}};let x=_wj(function*(a){let b=a.assocElem,c=_hf._Ei(b.value);yield _hf._Co(!0);for(let d of $("[name=refTab]",a)){a=_Xt($(d).closest("tseOper"));a=c.slice(0,a);a=yield _hf._fr(0,_hf._Aj,a,b.initialSet);d.initialSet=[[]];for(let e of a)if(e.length){d.initialSet=[e];break}$(d).triggerEvt("initialSetChange")}});const z="onCreated onRemoved onActivated onUpdated onHighlighted onMoved".split(" "),A=["onFocusChanged","onBoundsChanged"],B=_hf._Mu("<id>");
let L=_Et(function*(a,b,c,d){let e="";a=[{oper:"mergeGrp"}].concat(a);for(let h=0;h<a.length;++h){var g=a.slice(0,h+1);e+=`<step><header>${h?`Step ${h}:&nbsp;<oper>${f.opers[b[h-1].ufOper]}</oper>`:"Initial set"} ${h?"":" &nbsp; <h h=iSet></h>"}</header><cont>`;g=yield _hf._fr(0,_hf._Aj,g,c);for(let n of g){g=(g=a[h+1])&&"filter"==g.oper&&(g.params.pos?!g.params.pos.in("first","last"):_Kg(g.params.refExpr,"templ"))?_Kg(yield _hf._fr(0,_hf._Aj,[{oper:"filter",params:{tgtExpr:B,refExpr:B,refTab:a[h+
1].params.refTab}}],[n]),0,0):null;e+="<tabList>";n.length||(e+="<empty>empty group</empty>");for(let C of n){let D=_hf._os[C],E=_7j(D);e+=`<tab reftab=${C==g} url="${_5h(E)}"><img src="${_5h(_Tu(E))}"><t>${_5h(D.title)}</t></tab>`}e+="</tabList>"}e+="</cont></step>"}d(e)});return function(a){f.enumValues["<monitorId>"]={}.add([..._hf._h].map(([d,{name:e}])=>[d,e]));let b=_ne("tseEditorPane",void 0,F).prop("assocElem",a).prop("optionsCollection",f).attr("optionsCollection","");a.value||(a.value=[]);
0==a.value.length&&b.addClass("empty");for(let d of a.value)$(">operSeq",b).append(r(d));K(b);let c=_se(100,()=>w(b[0]));$(a).on("initialSetChange.tseEditor",c);0==$(a).closest("tseEditor").length&&(_5g(_Ky.tabs,z,c),_5g(_Ky.windows,A,c),$(window).on("focus blur",c));b.on("close",function(){$(a).off(".tseEditor");_Ki(_Ky.tabs,z,c);_Ki(_Ky.windows,A,c);$(window).off("",c)});x(b[0])(()=>{a.showTseResult&&b.attr("resViewer","on").append(v(a))});return b}}};
